<?php

// 会员积分记录

namespace app\console\model;

use think\Model;
use think\Request;
use app\client\model\Express as ExpressModel;

class MemberIntegral extends Model
{

    // 模型事件
    protected static function init()
    {
        // 写入之前
        self::event('before_write',function ($data){
            // 获取参数
            $information = Request::instance()->param();

            if ($information['status'] == 2) {
                $data->express_name = (new ExpressModel)->where(['code' => $information['express_value']])->value('name');
            }

        });
    }


    // 兑换记录 会员信息关联
    // public function Member()
    // {
    //     return $this->belongsToMany('Member','member_id','id')->field('id');
    // }

}